home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 18 / develop 18 code / OSA Sample / Sources / DebugTrace.cp < prev    next >
Encoding:
Text File  |  1994-01-28  |  1.1 KB  |  70 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        DebugTrace.cp
  4.  
  5.     Contains:    Debug helper implementation.
  6.  
  7.     Developed by:    
  8.         
  9.         Paul G Smith (commstalk hq & Full Moon Software, Inc)
  10.         
  11.         you can leave messages at (UK): 0727 844232; (US): 408 253 7199
  12.         BUT I prefer to be contacted by e-mail
  13.         AppleLink:     SMITH.PG
  14.         Internet:     SMITH.PG@applelink.apple.com
  15.         
  16.         "SimpliFace" Sample code to accompany develop article
  17.         on techniques for embedding scripts in applications.
  18.  
  19.  
  20.     To link the output of this file you need also to link with
  21.     file "DebugTranscript.lib".
  22.  
  23. */
  24.  
  25. #include "Stdio.h"
  26. #include "DebugTrace.h"
  27.  
  28.  
  29. #pragma trace off
  30.  
  31.  
  32.  
  33. // ------ debug helpers ----------------------------------
  34.  
  35. extern "C" {    // debug utility functions
  36.     pascal void SetDebugLevel(short);
  37.     pascal short GetDebugLevel(void);
  38. }
  39.  
  40. static short gOldDebugLevel;
  41. static short gWasDebugLevel;
  42.  
  43.  
  44. void SuspendDebug(void)
  45. {
  46.     gWasDebugLevel = GetDebugLevel();
  47.     SetDebugLevel(-2);
  48. }
  49.  
  50.  
  51. void ResumeDebug(void)
  52. {
  53.     SetDebugLevel(gWasDebugLevel);
  54. }
  55.  
  56.  
  57. void ForceDebug(void)
  58. {
  59.     gOldDebugLevel = GetDebugLevel();
  60.     SetDebugLevel(1);
  61. }
  62.  
  63.  
  64. void EndForceDebug(void)
  65. {
  66.     fflush(stdout);
  67.     SetDebugLevel( -2 /* gOldDebugLevel */ );
  68. }
  69.  
  70.